package ${baseProjectPackage}.web.controller;

import ${basePackage}.frm.core.entity.Result;
import ${basePackage}.frm.core.entity.ResultGenerator;
import ${baseProjectPackage}.model.${modelNameUpperCamel};
import ${baseProjectPackage}.service.${modelNameUpperCamel}Service;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import javax.annotation.Resource;
import java.util.List;

/**
 *
 * @author ${author}
 * @date ${date}
 */
@RestController
@RequestMapping("${baseRequestMapping}")
@Api(value = "${modelNameLowerCamel}" ,tags = {"${modelNameLowerCamel}"})
public class ${modelNameUpperCamel}Controller {

@Resource
private ${modelNameUpperCamel}Service ${modelNameLowerCamel}Service;

@PostMapping("/save")
@ApiOperation(value = "新增",notes = "新增")
public Result<String> save(${modelNameUpperCamel} ${modelNameLowerCamel}) {
${modelNameLowerCamel}Service.save(${modelNameLowerCamel});
return ResultGenerator.genSuccessResult("新增完成");
}

@PostMapping("/delete")
@ApiOperation(value = "删除",notes = "删除")
public Result<String> delete(@RequestParam String id) {
${modelNameLowerCamel}Service.deleteById(id);
return ResultGenerator.genSuccessResult("删除完成");
}

@PostMapping("/update")
@ApiOperation(value = "修改",notes = "修改")
public Result<String> update(${modelNameUpperCamel} ${modelNameLowerCamel}) {
${modelNameLowerCamel}Service.update(${modelNameLowerCamel});
return ResultGenerator.genSuccessResult("修改完成");
}

@PostMapping("/detail")
@ApiOperation(value = "详情",notes = "详情")
public Result<${modelNameUpperCamel}> detail(@RequestParam String id) {
${modelNameUpperCamel} ${modelNameLowerCamel} = ${modelNameLowerCamel}Service.findById(id);
return ResultGenerator.genSuccessResult(${modelNameLowerCamel});
}

@GetMapping("/queryList")
@ApiOperation(value = "不分页列表",notes = "不分页列表")
public Result<List<${modelNameUpperCamel}>> queryList() {
List<${modelNameUpperCamel}> list = ${modelNameLowerCamel}Service.findAll();
return ResultGenerator.genSuccessResult(list);
}

@GetMapping("/queryPage")
@ApiOperation(value = "分页列表",notes = "分页列表")
public Result<PageInfo<${modelNameUpperCamel}>> queryPage(Integer pageNum, Integer pageSize) {
PageInfo<${modelNameUpperCamel}> page = ${modelNameLowerCamel}Service.findPage(pageNum, pageSize);
return ResultGenerator.genSuccessResult(page);
}
}
